<template>
	<view>
		<uni-card title="菜单">
			<!-- <uni-card title="菜单" :extra="'积分:'+integral"> -->
			<uni-grid :column="3" :showBorder="false" :square="true" @change="menu">
				<!-- <uni-grid-item index="0" v-if="unionCount>0">
					<view class="grid-item-box">
						<uni-icons type="person" size="40"></uni-icons>
						<text class="text">我的联盟</text>
						<view class="grid-dot">
							<uni-badge :text="unionCount" type="primary" />
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item index="1">
					<view class="grid-item-box">
						<uni-icons type="plus" size="40"></uni-icons>
						<text class="text">创建联盟</text>
					</view>
				</uni-grid-item>-->

				<uni-grid-item index="7">
					<view class="grid-item-box">
						<uni-icons type="vip" size="40"></uni-icons>
						<text class="text">申请头衔</text>
					</view>
				</uni-grid-item>
				<uni-grid-item index="9">
					<view class="grid-item-box">
						<uni-icons type="list" size="40"></uni-icons>
						<text class="text">击杀数据</text>
					</view>
				</uni-grid-item>
				<uni-grid-item index="8">
					<view class="grid-item-box">
						<uni-icons type="gear" size="40"></uni-icons>
						<text class="text">头衔设置</text>
					</view>
				</uni-grid-item>
				<!-- <uni-grid-item index="3">
					<view class="grid-item-box">
						<uni-icons type="email" size="40"></uni-icons>
						<text class="text">留言建议</text>
					</view>
				</uni-grid-item>
				<uni-grid-item index="4">
					<view class="grid-item-box">
						<uni-icons type="help" size="40"></uni-icons>
						<text class="text">常见问题</text>
					</view>
				</uni-grid-item>
				<uni-grid-item index="5">
					<view class="grid-item-box">
						<uni-icons type="info" size="40"></uni-icons>
						<text class="text">关于我们</text>
					</view>
				</uni-grid-item>
				<uni-grid-item index="6">
					<view class="grid-item-box">
						<uni-icons type="email" size="40"></uni-icons>
						<text class="text">订阅提取</text>
					</view>
				</uni-grid-item> -->
			</uni-grid>

			<uni-popup ref="message" type="message" :value="popupMessage">
				<uni-popup-message :type="popupMessage.msgType" :message="popupMessage.messageText" :duration="1000">
				</uni-popup-message>
			</uni-popup>
		</uni-card>
		<view style="padding: 30rpx;">
			<ad unit-id="adunit-cd1eabec586c26eb"></ad>
			<view style="margin-top: 30rpx;font-size: 13px;border-radius:10px;background-color: #f4f8ff;">
				<view style="padding: 20rpx;">
					<text>
						<!-- 温馨提示：\n
						1.只有联盟创建者有权限进行数据“提取”,不进行“提取”是无法展示数据的\n
						2.只有加入联盟才可以看到对应联盟的数据\n
						3.本区数据只会展示本小程序中注册的联盟数据\n
						4.当小程序中的联盟创建者点击“提取”按钮并且未完成提取时,游戏中退出联盟,可能会造成此人的数据在小程序中无法展示\n\n
						更多问题请点击“常见问题” -->
						温馨提示：\n
						1.因为专注,所以专业\n
						2.头衔机器人 100/月\n
						3.DKP统计(战力前1000人) 100/月\n
						4.头衔机器人+DKP统计 150/月\n
						5.联系方式VX YelaSilent
					</text>
				</view>

			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				unionCount: 0,
				integral: 0,
				isAdmin: 0,
				serverId: null,
				serverCode: null,
				password: null,
				popupMessage: {
					type: 'center',
					msgType: 'success',
					messageText: '这是一条成功提示',
					value: ''
				}
			}
		},
		methods: {
			menu(e) {
				switch (e.detail.index) {
					case 0:
						uni.navigateTo({
							url: "/pages/union/union"
						})
						break
					case 1:
						uni.navigateTo({
							url: "/pages/addUnion/addUnion"
						})
						break
					case 2:
						uni.navigateTo({
							url: "/pages/joinUnion/joinUnion"
						})
						break
					case 3:
						uni.navigateTo({
							url: "/pages/propose/propose"
						})
						break
					case 4:
						uni.navigateTo({
							url: "/pages/help/help"
						})
						break
					case 5:
						uni.navigateTo({
							url: "/pages/about/about"
						})
						break
					case 6:
						var that = this;
						uni.requestSubscribeMessage({
							tmplIds: ['QHwd_XCdVJzQC8VDnjPfUSGVc8pkSnRHmiXouenF58o'],
							success(res) {
								that.popupMessage.msgType = "success"
								that.popupMessage.messageText = "订阅成功"
								that.$refs.message.open()
							}
						})
						break
					case 7:
						var that = this;
						uni.getUserProfile({
							desc: "用于完善会员资料",
							lang: "zh_CN",
							success: function(userProfile) {
								getApp().globalData.user.headImg = userProfile.userInfo.avatarUrl
								getApp().globalData.user.nickName = userProfile.userInfo.nickName
								uni.navigateTo({
									url: "/pages/title/title"
								})
							}
						})
						break
					case 8:
						var that = this;
						uni.getUserProfile({
							desc: "用于完善会员资料",
							lang: "zh_CN",
							success: function(userProfile) {
								getApp().globalData.user.headImg = userProfile.userInfo.avatarUrl
								getApp().globalData.user.nickName = userProfile.userInfo.nickName
								uni.navigateTo({
									url: "/pages/titleAdmin/titleAdmin"
								})
							}
						})
						break
					case 9:
						var that = this;
						uni.getUserProfile({
							desc: "用于完善会员资料",
							lang: "zh_CN",
							success: function(userProfile) {
								getApp().globalData.user.headImg = userProfile.userInfo.avatarUrl
								getApp().globalData.user.nickName = userProfile.userInfo.nickName
								uni.navigateTo({
									url: "/pages/dkp/dkp"
								})
							}
						})
						break
				}
			},
			onload() {
				// uni.request({
				// 	url: getApp().globalData.url + '/api/union/getMyUnionCount',
				// 	header: {
				// 		'content-type': 'application/json',
				// 		'token': getApp().globalData.token
				// 	},
				// 	success: (res) => {
				// 		if (res.data.code == "00000") {
				// 			this.unionCount = res.data.data
				// 		} else {
				// 			this.popupMessage.msgType = "error"
				// 			this.popupMessage.messageText = res.data.msg
				// 			this.$refs.message.open()
				// 		}
				// 	}
				// });
				uni.request({
					url: getApp().globalData.url + '/api/user/info',
					header: {
						'content-type': 'application/json',
						'token': getApp().globalData.token
					},
					success: (res) => {
						if (res.data.code == "00000") {
							this.integral = res.data.data.integral
							getApp().globalData.user.serverId = res.data.data.serverId
							getApp().globalData.user.serverCode = res.data.data.serverCode
							getApp().globalData.user.password = res.data.data.password
							getApp().globalData.user.coordinateX = res.data.data.coordinateX
							getApp().globalData.user.coordinateY = res.data.data.coordinateY
							getApp().globalData.user.title = res.data.data.title
							if (res.data.data.id == 1) {
								this.isAdmin = 1
							}
						} else {
							this.popupMessage.msgType = "error"
							this.popupMessage.messageText = res.data.msg
							this.$refs.message.open()
						}
					}
				});
			}
		},
		onLoad(option) {
			this.onload()
		},
		onShareAppMessage: function(options) {
			var that = this;
			var shareObj = {
				path: '/pages/menu/menu'
			};
			return shareObj;
		},
		onPullDownRefresh: function() {
			this.onload()
			uni.stopPullDownRefresh()
		}
	}
</script>

<style>
	.grid-item-box {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-dot {
		position: absolute;
		top: 5px;
		right: 15px;
	}

	.container {
		padding: 20rpx;
	}
</style>
